/*
 * @Author: ipk518 121206530@qq.com
 * @Date: 2023-10-12 11:00:27
 * @LastEditors: ipk518 121206530@qq.com
 * @LastEditTime: 2023-10-25 09:02:25
 * @FilePath: /etws-sxk/Middlewares/message/message.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#pragma once
#include <string>

enum class MsgKind: int16_t 
{
    Ok = 0,
    Unknown = -1,
    FileNotExist = -2,
    DirNotExist = -3,
    InvalidOperation = -4,
    ImcompleteIo = -5,
    ExternalLibError = -6,
    OsRelatedError = -7,
    IncorrectChecksum = -8,
    InvalidData = -9,
    InitFailed = -10,
    ExecuteFailed = -11,
    Timeout = -12,
    Busy = -13,
    InvalidArgument = -14,
    OpenFailed = -15,
    Receiving = -16,
    NotPassiveMode = -17,
    InvalidMessageReceiver = -18,

    ZhUnknown = -50,
    ZhFileNotExist = -51,
    ZhDirNotExist = -52,
    ZhInvalidOperation = -53,
    ZhImcompleteIo = -54,
    ZhExternalLibError = -55,
    ZhOsRelatedError = -56,
    ZhIncorrectChecksum = -57,
    ZhInvalidData = -58,
    ZhInitFailed = -59,
    ZhExecuteFailed = -60,
    ZhTimeout = -61,
    ZhBusy = -62,
    ZhInvalidArgument = -64,
    ZhOpenFailed = -65,
    ZhReceiving = -66,
    ZhSent = -67,
    ZhInvalidMessageReceiver = -68,


    ZhInitializing = 1,
    ZhTaskStart = 2,
    ZhRunning = 3,
    ZhAbort = 4,
    ZhDetecting = 5,
    ZhDoNotOperate = 6,
    ZhCompleted = 7,
    ZhExceed = 8,
    ZhReset = 9,

};

struct Message 
{
public:
    MsgKind m_kind;
    std::string m_message;
public:
    static Message create(MsgKind kind, const std::string &customizedInfo = "")noexcept;
    Message(MsgKind kind = MsgKind::Ok);
    virtual ~Message() = default;
    Message(const Message &another)noexcept;
    Message(Message &&another)noexcept;
    Message &operator=(const Message &rhs)noexcept;
    Message &operator=(Message &&rhs)noexcept;
    bool operator==(const Message &rhs)const noexcept;
    bool operator!=(const Message &rhs)const noexcept;
    bool isOk()const noexcept;
    explicit operator int()const noexcept;
    operator std::string()const noexcept;
    std::string toString()const noexcept;
    void appendInfo(const std::string &info)noexcept;
    int code()const noexcept;
    const std::string &message()const noexcept;
};